C     COPYRIGHT       NONE.  THIS CODE IS IN THE PUBLIC DOMAIN.
C     FILENAME        GEMINICATCHUPANDRENDEZVOUSPROGRAM/MAIN7.F
C     PURPOSE         THIS IS PART OF THE ORIGINAL 1965 SIMULATION
C                     PROGRAM FOR THE GEMINI 7/6 MISSION
C                     CATCH-UP AND RENDEZVOUS FLIGHT PHASES.
C                     THIS PARTICULAR FILE IS THE MAIN FILE FOR
C                     PROGRAM MAIN7 (ENVIRONMENT), BY FERNEY HOUGH
C                     OF IBM OWEGO, WITH VARIOUS SUBROUTINES
C                     APPEARING IN SEPARATE SOURCE FILES.
C     WEBSITE         WWW.IBIBLIO.ORG/APOLLO (ALL LOWER CASE, PLEASE)
C     HISTORY         2010-08-12 RSB  BEGAN TRANSCRIBING FROM
C                                     THE SCANNED PDF REPORT.
C       	      2010-09-02 RSB  ADDED STUFF TO ACCOUNT FOR THE
C                                     FACT THAT CALL DEV AND 
C                                     CALL PRT ARE SUPPOSED TO 
C				      RETURN TO THE POINT AFTER CALL
C                                     MAR.  OH, FERNEY HOUGH, WHY
C 				      HAST THOU DONE THIS TERRIBLE
C				      THING.
C
C     THE FOLLOWING COMMENTS APPLY NOT ONLY TO THIS SOURCE FILE, BUT
C     TO ALL SOURCE FILES WITHIN THE PARENT FOLDER.
C
C     THIS SOURCE CODE WAS MANUALLY ENTERED BY READING THE SCANNED
C     PDF FILE GEMINI CATCH-UP AND RENDEZVOUS ANALYSIS AND SIMULATION
C     REPORT 4, DATED DECEMBER 31, 1965, PRESERVED BY EUGENE
C     MERTZ AND SCANNED BY DAVE MERTZ. (REFER TO THE WEBSITE LINK
C     ABOVE FOR THE FULL DOCUMENT.)  THE SOURCE FILE THEN UNDERWENT
C     EXTENSIVE PROOFING.
C
C     THE PROGRAM ITSELF APPEARS TO BE WRITTEN IN FORTRAN II, INTERMIXED
C     WITH ASSEMBLY LANGUAGE FOR THE IBM 7090/7094 MAINFRAME ON WHICH
C     IT RAN.  IT THEREFORE CANNOT BE MEANINGFULLY COMPILED AS-IS WITH
C     ANY MODERN FORTRAN COMPILER.  NOTE, HOWEVER, THE EXISTENCE OF AN
C     IBM 7090/7094 SIMULATOR ON WHICH IT MAY BE POSSIBLE TO RUN AN
C     UNMODIFIED VERSION OF THIS PROGRAM. MODIFIED VERSIONS OF THE
C     PROGRAM WHICH CAN BE COMPILED WITH (FOR EXAMPLE) GNU FORTRAN
C     WILL BE PROVIDED AT VIRTUAL AGC PROJECT WEBSITE AS THEY BECOME
C     AVAILABLE.
C
C     TO A CERTAIN EXTENT, IT HAS BEEN POSSIBLE TO PERFORM SOME SYNTAX
C     CHECKING OF THE FORTRAN SOURCE FILES BY COMPIING WITH FORTRAN 66
C     (I.E., USING THE GNU FORTRAN COMPILER G77 WITH THE APPROPRIATE
C     COMMAND-LINE SWITCHES.)  IN ORDER TO DO THIS, IT IS NECESSARY
C     TO TEMPORARILY REMOVE THE PARAMETRIZED LIST OF SWITCH SETTINGS
C     WHICH ACCOMPANY END-STATEMENTS.
C
C     THE ORIGINAL CODE HAS BEEN PRESERVED AS FAR AS IT HAS BEEN POSSIBLE
C     FOR ME TO DO SO, INCLUDING POSITIONING OF WHITE-SPACE, EXCEPT FOR
C     THE FOLLOWING --
C     1. A HEADER COMMENT BLOCK (SUCH AS THIS ONE) HAS BEEN ADDED TO
C        EACH SOURCE FILE.
C     2. COMMENTS HAVE BEEN ADDED TO SHOW HOW THE SOURCE CODE ALIGNS
C        TO THE PAGE BREAKS IN THE REPORT FROM WHICH THE SOURCE WAS
C        TAKEN.
C     3. ALL LINE LABELS ARE ALIGNED AT COLUMN 2. FORTRAN II WAS
C        INSENSITIVE TO THE POSITIONING, AS LONG AS THE ENTIRE LABEL
C        WAS CONFINED TO COLUMNS 2-7, BUT THE FORTRAN 66 COMPILER I
C        AM USING FOR CHECKING IS NOT INSENSITIVE TO THE ALIGNMENT.
C     4. CONTINUATION CHARACTERS IN COLUMN 8 HAVE BEEN REPLACED BY
C        1 WHEN * WAS ORIGINALLY USED, AGAIN BECAUSE THE FORTRAN 66
C        COMPILER DOES NOT ACCEPT *.
C     5. SOME LINES WHICH WERE BROKEN INTO TWO BY CONTINUATIONS IN WAYS
C        NOT RECOGNIZED BY THE THE FORTRAN 66 COMPILER HAVE BEEN
C        INSTEAD BROKEN AT DIFFERENT POINTS.
C     ALL ADDED COMMENTS CONFINE THEMSELVES TO THE FORTRAN II
C     CHARACTER-SET, WHICH IS VERY LIMITED (UPPER-CASE ONLY, VARIOUS
C     PUNCTUATION MARKS MISSING). THIS UNFORTUNATELY MEANS THAT LISTED
C     FILENAMES AND WEB-LINKS ARE TYPICALLY INCORRECT.  THIS IS WHY,
C     FOR EXAMPLE, THERE IS NO WEB-LINK PROVIDED FOR THE IBM 7090/7094
C     SIMULATOR SOFTWARE -- THE CHARACTERS IN THE LINK WOULD BE ILLEGAL.
C
C     THE ORIGINAL SOURCE CODE'S COMMENTS ARE RETAINED, BUT THEY WERE
C     FEW AND FAR-BETWEEN.  TO UNDERSTAND THE CODE, IT NEEDS TO BE
C     COMPARED WITH EXTERNAL DOCUMENTATION SUCH AS THE ORIGINAL REPORT.
C     PAGE NUMBERS IN THE ADDED COMMENTS REFER TO THE PAGES IN THE PDF
C     FILE AND NOT TO PAGE NUMBERING PRINTED ON THE ORIGINAL HARDCOPY OF
C     THE REPORT.
C
C     FROM PAGE 69 OF THE REPORT 
      DIMENSION CXT(11),CYT(11),CZT(11),CDTWT(11),VLIST(1),DLIST(100),
     *ILIST(100),SLIST(100),TLIST(100)
      DIMENSION REM(165),ITH(10),SC(14),TARG(14),TABLE1(50,20),
     *PSLST(50),IPLST(50),RKK(50)
      COMMON CDVXSP,CDVYSP,CDVZSP,CDPHSC,CDPSSC,CDTHSC,AKX1  ,AKX2  ,
     1AKX3  ,AKX4  ,AKYI  ,AKY2  ,AKY3  ,AKY4  ,AKZI  ,AKZ2  ,AKZ3  ,
     2AKZ4  ,ASFX  ,ASFY  ,ASFZ  ,CO    ,COI   ,C2    ,C2I   ,CA11  ,
     3CA12  ,CAI3  ,CA21  ,CA22  ,CA23  ,CA31  ,CA32  ,CA33  ,CAPT  ,
     4CAPTI ,CATXBA,CATXBI,CCAB  ,CCABI ,CCAS  ,CCAS1 ,CCK1  ,CCK2  ,
     5CCK3  ,CCK4  ,CCKS  ,CCKF  ,CCKG  ,CCPHIB,CCPSIB,CCPSIR,CCR   ,
     6CCRB  ,CCRBI ,CCRI  ,CCRS  ,CCRSI ,CCTHB ,CCTHR ,CCWSTD,CCWTOL,
     7CCZT  ,CDEL  ,CDRRD ,CDTM  ,CDTW  ,CDTWT ,CDTWX ,CDTX  ,CDV   ,
     8CDVF  ,CDVI  ,CDVT  ,CDVXB ,CDVXM ,CDVXS ,CDVXZ ,CDVYB ,CDVYM ,
     9CDVYS ,CDVYZ ,CDVZB ,CDVZM ,CDVZS ,CDVZZ ,CDXD  ,CDXFD ,CDYD
      COMMON CDYFD ,CDZD  ,CDZFD ,CFX   ,CFY   ,CFZ   ,CM1   ,CM3   ,
     1CM4   ,CM5   ,CM6   ,CNPC  ,CNS   ,CNVX  ,CNVY  ,CNVZ  ,CNYC  ,
     2COEFF ,COINT ,COMGS ,CPHIB ,CPHIBC,CPSBCP,CPSIB ,CPSIBC,CPSIBM,
     3CR1   ,CRA   ,CRLO  ,CRR   ,CRRD  ,CRRG  ,CRRI  ,CRRPI ,CRS   ,
     4CSADPI,CSAPG ,CSAPI ,CSAPR ,CSPHIB,CSPSIB,CSPSIR,CSRDPI,CSRPG ,
     5CSRPI ,CSRPR ,CSRT  ,CSRTI ,CSTD  ,CSTOL ,CSTHB ,CSTHR ,CSTZ  ,
     6CSWSTD,CSWTDL,CT    ,CTD   ,CTDAS ,CTDV  ,CTHB  ,CTHBC ,CTHBCP,
     7CTHBM ,CTLRP ,CTM   ,CTR1  ,CTRR  ,CTTG  ,CTW   ,CTX   ,CUDPHS,
     8CUDPSS,CUDTHS,CWSTD ,CWSTDL,CWTTPR,CX    ,CXM   ,CXRD  ,CXSD  ,
     9CXT   ,CXTD  ,CXZ   ,CY    ,CYM   ,CYRD  ,CYSD  ,CYT   ,CYTD
      COMMON CYZ   ,CZ    ,CZM   ,CZRD  ,CZSD  ,CZT   ,CZTD  ,CZZ   ,
     1DELAY ,DONPRT,DT    ,DUM1  ,DUM2  ,DUM3  ,DUM4  ,DUM5  ,DUM6  ,
     2DUM7  ,DUM8  ,DUM9  ,DUM10 ,DUM11 ,DUM12 ,DUM13 ,DUM14 ,DUM15 ,
     3DUM16 ,DUMI7 ,DUMI8 ,FIN   ,FP    ,FXP   ,FXPP  ,FYP   ,FYPP  ,
     4FZP   ,FZPP  ,GC    ,IC    ,IEXIT ,IOLP  ,IWRITE,K2C   ,KC    ,
     5KWRITE,L     ,LC1   ,LC1J  ,LC2   ,LC3   ,LC4A  ,LC4B  ,LC4C  ,
     6LC4D  ,LC4E  ,LC4F  ,LC4G  ,LC5   ,LC7   ,LC8   ,LC10  ,LCA   ,
     7LCS   ,LCY   ,LDI00 ,LDI10 ,LDI11 ,LDI13 ,LDI20 ,LDI21 ,LDI22 ,
     8LDI25 ,LDI26 ,LDI31 ,LDO01 ,LDO05 ,LDO11 ,LDO12 ,LDO13 ,LDO62 ,
     9LDO63 ,LFDI  ,LQT   ,M     ,N     ,PHIB  ,PINT  ,PSIB  ,RDGD
      COMMON RRDREF,SRAA  ,SREA  ,SW    ,TEST  ,TFTXV ,TFTYV ,TFTZV ,
     1THETAB,TIME  ,TPC   ,TRI   ,TSC   ,TVX   ,TVY   ,TVZ   ,TYC   ,
     2XGRT  ,XGRTD ,XKRDR ,YGRT  ,YGRTD ,ZGRT  ,ZGRTD
      EQUIVALENCE (DELVX,CDVXSP),(DELVY,CDVYSP),(DELVZ,CDVZSP),
     1(CDPHSC,DPHIB),(CDPSSC,DPSIB),(CDTHSC,DTHB),(VLIST,CDVXSP)
      EQUIVALENCE   (XI  ,SC( 1)),(YI  ,SC( 2)),(ZI  ,SC( 3)),
     1(TI  ,SC( 4)),(DXI ,SC( 5)),(DYI ,SC( 6)),(DZI ,SC( 7)),
     2(SCVM,SC( 8)),(RJ  ,SC( 9)),(DTT ,SC(10)),(Q37 ,SC(11)),
     3(Q38 ,SC(12)),(Q39 ,SC(13))
      EQUIVALENCE     (XTI ,TARG( 1)),(YTI ,TARG( 2)),(ZTI ,TARG( 3)),
     1(TTI ,TARG( 4)),(DXTI,TARG( 5)),(DYTI,TARG( 6)),(DZTI,TARG( 7)),
     2(TVM ,TARG( 8)),(RJJ ,TARG( 9)),(DTTP,TARG(10))
      EQUIVALENCE    (A11 ,RKK(50)),(A12 ,RKK(49)),(A13 ,RKK(48)),
     1(A21 ,RKK(47)),(A22 ,RKK(46)),(A23 ,RKK(45)),(A31 ,RKK(44)),
     2(A32 ,RKK(43)),(A33 ,RKK(42)),(DA11,RKK(41)),(DA12,RKK(40)),
     3(DA13,RKK(39)),(DA21,RKK(38)),(DA22,RKK(37)),(DA23,RKK(36)),
     4(DA31,RKK(35)),(DA32,RKK(34)),(DA33,RKK(33))
      ZZ1=CLOCKF(XX)
      CALL HDA7
      CALL SELFLD
      KT1= 5
C
C     FROM PAGE 70 OF THE REPORT 
      KT2= 9
      KT3= 14
      CALL LDB6
      READ INPUT TAPE KT1,1032,(REM(I),I=1,165)
330   ZZ2=CLOCKF(XX)
      DO 331  I=  1, 20
      DO 331  J= 1,50
331   TABLE1(J,I)=0.
      DO 332 I=  1, 50
332   RKK(I)=0.
      DO 333 I= 1,14
      SC(I)  =0.
333   TARG(I)=0.
      DO 334 I= 1,331
334   VLIST(I)=0.
      READ INPUT TAPE KT1,1010,NDATE1,NDATE2,NDATE3,NRUN1,NRUN2
      READ INPUT TAPE KT1,1002,   EOP   ,STCT  ,CTZ   ,CTE   ,COINT ,
     1DELAY ,ESPR  ,DT    ,BINT  ,CAPT  ,COMGT ,CSRT  ,XI    ,YI    ,
     2ZI    ,DXI   ,DYI   ,DZI   ,XTI   ,YTI   ,ZTI   ,DXTI  ,DYTI  ,
     3DZTI  ,RJ    ,CATXBA,CATXFW,CATYB ,CATZB ,XKRDR ,CCAB  ,CCAS  ,
     4CCRB  ,CCRS  ,C0    ,C2    ,A11   ,A12   ,A13   ,A21   ,A22   ,
     5A23   ,A31   ,A32   ,A33   ,AKX1  ,AKX2  ,AKX3  ,AKX4  ,AKY1  ,
     6AKY2  ,AKY3  ,AKY4  ,AKZ1  ,AKZ2  ,AKZ3  ,AKZ4  ,XKP1  ,XKP2  ,
     7XKP3  ,XKR   ,XKY   ,CCR
      READ INPUT TAPE KT1,1001,(ITH(I),I=1,10) ,MACOP ,MACNTR,MACINT,
     1MODCR ,NPF   ,LOC   ,LMDI
      READ INPUT TAPE KT1,1012,          LFP   ,LGANG ,LRR   ,LSRA  ,
     1LRM   ,LDB   ,LFDI  ,IEXIT
      READ INPUT TAPE KT1,1005,KEYSET
57    CALL KEYCN (KOMBO)
      IF (KEYSET-KOMBO) 58,59,58
58    PRINT 1017,KEYSET
      PAUSE
      GO TO 57
59    WRITE OUTPUT TAPE KT2,1037, EOP   ,STCT  ,CTZ   ,CTE   ,COINT ,
     1DELAY ,ESPR  ,DT    ,BINT  ,CAPT  ,COMGT ,CSRT  ,XI    ,YI    ,
     2ZI    ,DXI   ,DYI   ,DZI   ,XTI   ,YTI   ,ZTI   ,DXTI  ,DYTI  ,
     3DZTI  ,RJ    ,CATXBA,CATXFW,CATYB ,CATZB ,XKRDR
      WRITE OUTPUT TAPE KT2,1038, CCAB  ,CCAS  ,CCRB  ,CCRS  ,C0    ,
     2C2    ,A11   ,A12   ,A13   ,A21   ,A22   ,A23   ,A31   ,A32   ,
     2A33   ,AKX1  ,AKX2  ,AKX3  ,AKX4  ,AKY1  ,AKY2  ,AKY3  ,AKY4  ,
     3AKZ1  ,AKZ2  ,AKZ3  ,AKZ4  ,XKP1  ,XKP2  ,XKP3
      WRITE OUTPUT TAPE KT2,1039, XKR   ,XKY   ,CCR
      WRITE OUTPUT TAPE KT2,1040,(ITH(I),I=1,10),MACOP ,MACNTR,MACINT,
     1MODCR ,NPF   ,LOC   ,LMDI  ,LFP   ,LGANG ,LRR   ,LSRA  ,LRM   ,
     2LDB   ,LFDI  ,IEXIT
      WRITE OUTPUT TAPE KT2,1011,NDATE1,NDATE2,NDATE3,NRUN1,NRUN2
      PRINT 1013,NOATE1,NDATE2,NDATE3,NRUN1,NRUN2
      IF (LMDI) 115,125,115
115   IPL=0
108   IPL=IPL+1
      IF(IPL-100) 116,116,109
116   READ INPUT TAPE KT1,1050,SLIST(IPL),TLIST(IPL),DLIST(IPL),
     1ILIST(IPL)
      IF(ILIST(IPL)) 108,109,108
109   JK=IPL
C
C     FROM PAGE 71 OF THE REPORT 
      WRITE OUTPUT TAPE KT2,1051
      DO 113 I=1,JK
113   WRITE OUTPUT TAPE KT2,1052,SLIST(I),TLIST(I),DLIST(I),ILIST(I)
125   IF (LOC) 252,94,252
252   READ INPUT TAPE KT1,1014,LIMIT,(PSLST(LPL),IPLST(LPL),LPL=1,2)
      IF (LIMIT-2) 903,903,251
251   READ INPUT TAPE KT1,1015,(PSLST(LPL),IPLST(LPL),LPL=3,LIMIT)
903   WRITE OUTPUT TAPE KT2,1016,(PSLST(LPL),IPLST(LPL),LPL=1,LIMIT)
      CALL HDA9
94    IF (MACOP) 95,96,95
95    RT= ZTI
      RAD=.01745329
      THT=XTI*RAD
      PHT=YTI*RAD
      GAT=DXTI*RAD
      PST=YTI*RAD
      CTHT=COSF(THT)
      STHT=SINF(THT)
      CPHI=COSF(PHT)
      SPHT=SINF(PHT)
      XTI=RT*CTHT*CPHT
      YTI=RT*STHT*CPHT
      ZTI=RT*SPHT
      CGAT=COSF(GAT)
      SGAT=SINF(GAT)
      CPST=COSF(PST)
      SPST=SINF(PST)
      DXTI=DZTI*(CTHT*(CPHT*SGAT-SPHT*CPST*CGAT)-STHT*SPST*CGAT)
      DYTI=DZTI*(STHT*(CPHT*SGAT-SPHT*CPST*CGAT)+CTHT*SPST*CGAT)
      DZTI=DZTI*(SPHT*SGAT+CPHT*CPST*CGAT)
      RDT=(XTI*DXTI+YTI*DYTI+ZTI*DZTI)/RT
      IF(MACNTR)98,97,98
98    RF=YI +RT
      AZTF=ATN1F(ZI ,RT)
      AXTF=XI /RT
      SINX=SINF(AXTF)
      COSX=COSF(AXTF)
      SINZ=SINF(AZTF)
      COSZ=COSF(AZTF)
      PHX=ARSINF(COSX*SPHT-SINX*CPHT*CPST)
      SPHX =SINF(PHX)
      CPHX =COSF(PHX)
      DTHX=ARSINF(SINX*SPST/CPHX)
      THX =THT    -DTHX
      PSX1 =COSF(DTHX)*CPST
      PSX2 =SINF(DTHX)*SPST*SPHT
      IF(XI ) 28,28,29
29    PSX=ARCOSF(PSX1+PSX2)
      GO TO 30
28    PSX=ARCOSF(-PSX1+PSX2)
30    PHF=ARSINF(COSZ*SPHX+SINZ*CPHX*SINF(PSX))
      DTHF=ARSINF(SINZ*COSF(PSX)/COSF(PHF))
      THF =THX-DTHF
      U233 =PHF/RAD
      U234 =THF/RAD
      ZI=RF*SINF(PHF)
C      
C     FROM PAGE 72 OF THE REPORT 
      XI=RF*COSF(PHF)*COSF(THF)
      YI=RF*COSF(PHF)*SINF(THF)
      SF=YTI*DZTI-ZTI*DYTI
      SG=ZTI*DXTI-XTI*DZTI
      SH=XTI*DYTI-YTI*DXTI
      SJ=SQRTF(SF**2+SG**2+SH**2)
      HT=SJ/RT
      BOB1=ZTI*SG-YTI*SH
      BOB2=XTI*SH-ZTI*SF
      BOB3=YTI*SF-XTI*SG
      BOBL= SQRTF(BOB1**2+BOB2**2+BOB3**2)
      P= BOB3*YI-BOB2*ZI
      Q= BOB1*ZI-BOB3*XI
      S= BOB2*XI-BOB1*YI
      BIGD=2.E-8*(-SJ*RF**2/RT)*(DXI -RDT*AXTF-HT)
      BIGE=2.E-8*RF*(DYI +RDT)
      BIGF=2.E-8*RF*BOBL*DZI
      BIGA=2.E-8*SG*ZI-2.E-8*SH*YI
      BIGB=2.E-8*SH*XI-2.E-8*SF*ZI
      BIGC=2.E-8*SF*YI-2.E-8*SG*XI
      DEL=BIGA*YI*(4.E-16*S) + BIGB*ZI*(4.E-16*P) + BIGC*XI*(4.E-16*Q)
     1   -BIGC*YI*(4.E-16*P) + BIGB*XI*(4.E-16*S) - BIGA*ZI*(4.E-16*Q)
      C11= YI*(4.E-16*S) - ZI*(4.E-16*Q)
      C21= BIGB*(2.E-8*S) - BIGC*(2.E-8*Q)
      C22= BIGA*(2.E-8*S) - BIGC*(2.E-8*P)
      C31= 2.E-8*(BIGB*ZI-BIGC*YI)
      C12= XI*(4.E-16*S) - ZI*(4.E-16*P)
      C32= 2.E-8*(BIGA*ZI-BIGC*XI)
      C13= XI*(4.E-16*Q) - YI*(4.E-16*P)
      C23= BIGA*(2.E-8*Q) - BIGB*(2.E-8*P)
      C33= 2.E-8*(BIGA*YI-BIGB*XI)
      DELD=BIGD/DEL
      DELE=BIGE/DEL
      DELF=BIGF/DEL
      DZI=C13*DELD-C23*DELE+C33*DELF
      DYI=-C12*DELD+C22*DELE-C32*DELF
      DXI=C11*DELD-C21*DELE+C31*DELF
      GO TO 96
97    CTHF =COSF (XI  *RAD)
      STHF =SINF (XI  *RAD)
      CPHF =COSF( YI  * RAD)
      SPHF= SINF (YI  * RAD)
      XI=ZI *CTHF * CPHF
      YI=ZI *STHF * CPHF
      ZI=ZI *SPHF
      CGAF = COSF(DXI* RAD)
      SGAF =SINF(DXI* RAD)
      CPSF= COSF(DYI * RAD)
      SPSF= SINF (DYI * RAD)
      DXI=DZI * (CTHF*(CPHF * SGAF- SPHF*CPSF*CGAF)- STHF*SPSF *CGAF)
      DYI=DZI * (STHF*(CPHF* SGAF-SPHF* CPSF* CGAF)+ CTHF *SPSF*CGAF)
      DZI=DZI *(SPHF * SGAF +CPHF * CPSF*CGAF)
96    TI=SQRTF(XI**2+YI**2+ZI**2)
      TTI=SQRTF(XTI**2+YTI**2+ZTI**2)
      RJJ=RJ
      IF (MACINT) 995,996,995
C      
C     FROM PAGE 73 OF THE REPORT 
995   DXI=-DXI
      DYI=-DYI
      DZI=-DZI
      DXTI=-DXTI
      DYTI=-DYTI
      DZTI=-DZTI
      DTT=10.*DT
      DTTP=DTT
990   CALL STATE (SC)
      CALL STATE (TARG)
      T=T+DTT
992   IF (T-BINT)  990,989,989
989   WRITE OUTPUT TAPE KT2,642,T,NDATE1,NDATE2,NDATE3,NRUN1,NRUN2
      WRITE OUTPUT TAPE KT2,643,XI,YI,ZI
      WRITE OUTPUT TAPE KT2,644,DXI,DYI,DZI
      WRITE OUTPUT TAPE KT2,645,XTI,YTI,ZTI
      WRITE OUTPUT TAPE KT2,644,DXTI,DYTI,DZTI
      DXI=-DXI
      DYI=-DYI
      DZI=-DZI
      DXTI=-DXTI
      DYTI=-DYTI
      DZTI=-DZTI
996   T=CTZ
      KPLOT= 0
      MUD5=0
851   ZZ=CLOCKF(XX)
      PRINT 1004
      CO=CTZ
      XLIMIT=.20
      GC=1.407654E+16
      RE=2.0925874E+07
      ICC=1
      JUMP=0
      LDI22=0
      MM=0
      IPL=1
      ITAG=0
      INPASS=0
      INITAL=0
      TRIDOT=0.
553   IF (MODCR-1) 554,555,102
554   LDI10=0
      LDI11=4095
      LDI13=0
      GO TO 102
555   LDI10=4095
      LDI11=0
      LDI13=4095
      GO TO 102
101   DTT=DT
      DTTP=DTT
      CALL STATE (SC)
      CALL STATE (TARG)
      T=T+DTT
102   TIME =T
C  
C     FROM PAGE 74 OF THE REPORT 
      IF (ITH(ICC)) 71,72,71
71    DXPFO=P11*Q37+P21*Q38+P31*Q39
      DYPFO=P12*Q37+P22*Q38+P32*Q39
      DZPFO=P13*Q37+P23*Q38+P33*Q39
      FXP=FXP+DXPFO*DT
      FYP=FYP+DYPFO*DT
      FZP=FZP+DZPFO*DT
      FXP1=FXP
      FYP1=FYP
      FZP1=FZP
      TFTXV=TFTXV+ABSF(FTXV)*DT
      TFTYV=TFTYV+ABSF(FTYV)*DT
      TFTZV=TFTZV+ABSF(FTZV)*DT
72    OMEGA=ATN1F((DZI*YI-DYI*ZI),(DZI*XI-DXI*ZI))
      Q30=SINF(OMEGA)
      Q31=COSF(OMEGA)
      OIOTA=ARCOSF((DYI*XI-DXI*YI)/(TI*SCVM))
      OMU=ARCOSF((XI*Q32+YI*Q30)/TI)
      IF (ZI) 700,704,704
700   OMU=-OMU
704   Q32=SINF(OMU)
      Q33=COSF(OMU)
      Q34=SINF(OIOTA)
      Q35=COSF(OIOTA)
      P11=-Q32*Q31-Q33*Q30*Q35
      P12=-Q33*Q31+Q32*Q30*Q35
      P13=Q34*Q30
      P21=Q33*Q31*Q35-Q32*Q30
      P22=-Q33*Q30-Q32*Q31*Q35
      P23=-Q31*Q34
      P31=Q33*Q34
      P32=-Q32*Q34
      P33=Q35
      PB11=A11*P11+A21*P21+A31*P31
      PB12=A11*P12+A21*P22+A31*P32
      PB13=A11*P13+A21*P23+A31*P33
      PB21=A12*P11+A22*P21+A32*P31
      PB22=A12*P12+A22*P22+A32*P32
      PB23=A12*P13+A22*P23+A32*P33
      PB31=A13*P11+A23*P21+A33*P31
      PB32=A13*P12+A23*P22+A33*P32
      PB33=A13*P13+A23*P23+A33*P33
      PHIB=ATN1F(PB33,-PB23)
      THETAB=ATN1F(-PB12,PB11)
      Q82=ABSF(SINF(PHIB))
      IF(Q82-.4)601,601,602
601   PSIB=ATN1F(-PB13,-PB23/COSF(PHIB))
      GO TO 603
602   PSIB=ATN1F(-PB13,PB33/SINF(PHIB))
603   CONTINUE
      IF (LDO05) 551,552,551
551   SENSE LIGHT 4
      GO TO 556
552   IF(SENSE LIGHT 4) 556,556
556   IF(LDI 21) 114,428,114
428   CALL KEYS (17,KEY17)
C  
C     FROME PAGE 75 OF THE REPORT 
      IF (KEY17) 427,300,427
427   LDI21=2047
      TSC=T
      GO TO 114
300   IF (T-STCT) 114,110,110
110   LDI21=4095
      TSC=T
114   IF(LMDI) 104,111,104
104   IF(T-TLIST(IPL))111,105,105
105   K=ILIST(IPL)
      IF(LMDI) 107,106,106
106   VLIST(K)=DLIST(IPL)
      GO TO 117
107   CALL INSERT (ILIST(IPL),DLIST(IPL),SLIST(IPL))
117   IPL=IPL+1
118   IF(K-288) 104,119,104
119   IF(LDI21) 122,104,122
122   TSC=T
      GO TO 104
111   XRI=XTI-XI
      YRI=YTI-YI
      ZRI=ZTI-ZI
      TRI=SQRTF(XRI**2+YRI**2+ZRI**2)
126   IF(INPASS) 127,128,127
127   TRIDOT=(TRI-TRI1)/DT
128   TRI1=TRI
767   XRV=A11*XRI+A21*YRI+A31*ZRI
      YRV=A12*XRI+A22*YRI+A32*ZRI
      ZRV=A13*XRI+A23*YRI+A33*ZRI
      RAA=6.28318530-ATN1F(YRV,SQRTF(XRV**2+ZRV**2))
      IF (RAA-25./57.2957795) 761,761,762
762   IF (RAA-335./57.2957795) 763,761,761
761   SRAA=(SINF(RAA)-CCRB)/(1.+CCRS)
      REAPR=SQRTF(XRV**2+YRV**2)
      REA=ATN1F(ZRV,SIGNF(REAPR,XRV))
      IF (REA-25./57.2957795) 764,764,765
765   IF (REA-335./57.2957795) 763,764,764
764   SREA=(SINF(REA)-CCAB)/(1.+CCAS)
197   IF (ABSF(WXV   )-.02618) 768,768,763
768   IF (ABSF(WYV   )-.02618) 769,769,763
769   IF (ABSF(WZV   )-.02618) 766,766,763
766   IF(LQT) 763,448,763
448   LDI00=4095
      GO TO 449
763   LDI00=0
449   IF(LFDI) 450,455,450
450   IF(LDI21) 451,454,451
451   IF(CTX-200.) 456,452,452
452   IF(LDO05) 453,456,453
455   IF(CRLO) 450,456,450
453   IF(LDI00) 454,456,454
454   LRDFDI=4095
      GO TO 787
456   LRDFDI=0
787   RADTD=(XTI*DXTI+YTI*DYTI+ZTI*DXTI)/TTI
      GAMT=ARSINF(RADTD/TVM)
C
C     FROM PAGE 76 OF THE REPORT 
      THET=ATN1F(YTI,XTI)
      PHIT=ARSINF(ZTI/TTI)
      PSIT=ATN1F((XTI*DYTI-YTI*DXTI),(TTI *DZTI-ZTI*RADTD))
      STHET=SINF(THET)
      CTHET=COSF(THET)
      SPHIT=SINF(PHIT)
      CPHIT=COSF(PHIT)
      SPSIT=SINF(PSIT)
      CPSIT=COSF(PSIT)
      T11=STHET*SPSIT+CTHET*CPSIT*SPHIT
      T12=CPHIT*CTHET
      T13=STHET*CPSIT-CTHET*SPSIT*SPHIT
      T21=-CTHET*SPSIT+STHET*CPSIT*SPHIT
      T22=CPHIT*STHET
      T23=-CTHET*CPSIT-STHET*SPSIT*SPHIT
      T31=-CPHIT*CPSIT
      T32=SPHIT
      T33=CPHIT*SPSIT
      XP=T11*XI+T21*YI+T31*ZI
      YP=T12*XI+T22*YI+T32*ZI
      ZP=T13*XI+T23*YI+T33*ZI
      XPD=T11*DXI+T21*DYI+T31*DZI
      YPD=T12*DXI+T22*DYI+T32*DZI
      ZPD=T13*DXI+T23*DYI+T33*DZI
      TEMP=ATN1F(XP,Y)
      IF(TEMP-3.14159265) 772,772,771
771   TEMP=TEMP-6.28318530
772   XGRT=TTI *TEMP
      TEMP2=XP**2+YP**2
      TEMP1=SQRTF(TEMP2)
      YGRT=TEMP1-TTI
      ZGRT=ZP
      CGAMT=COSF(GAMT)
      XGRTD=TTI *(YP*XPD-XP*YPD)/TEMP2+RADTD*TEMP+TVM *CGAMT
      YGRTD=-RADTD+(XP*XPD+YP*YPD)/TEMP1
      ZGRTD=ZPD
920   CONTINUE
      PHIBS =PHIB
      THBS  =THETAB
      PSIBS =PSIB
      TRIS  =TRI
      SRAAS =SRAA
      SREAS =SREA
      IF (LFT) 421,420,421
421   FXP =FXP +FXPSV
      FYP =FYP +FYPSV
      FZP =FZP +FZPSV
      FXPS=FXP
      FYPS=FYP
      FZPS=FZP
      CALL QUANT (FXP,.11)
      CALL QUANT (FYP,.11)
      CALL QUANT (FZP,.11)
      FXPSP=FXP
      FYPSP=FYP
      FZPSP=FZP
C
C     FROM PAGE 77 OF THE REPORT 
      FXPSV=FXPS-FXP
      FYPSV=FYPS-FYP
      FZPSV=FZPS-FZP
420   IF (LGANG) 401,400,401
401   CALL QUANT (PHIB  ,.036/57.2957795)
      CALL QUANT (THETAB,.036/57.2957795)
      CALL QUANT (PSIB  ,.036/57.2957795)
400   IF (LRR) 403,402,403
403   CALL QUANT (TRI   ,49.178)
402   IF (LSRA) 405,422,405
405   CALL QUANT (SRAA  ,.42594791*.1953125E-2)
407   CALL QUANT (SREA  ,.42594791*.1953125E-2)
422   IF (LRM) 423,408,423
423   IF (TRI-1510797.) 408,424,424
424   TRI=1510797.
408   CALL CTRL1
640   CONTINUE
      IF (LDO62) 426,901,426
901   LDI21=0
426   LDO62=4095
      PHIB  =PHIBS
      THETAB=THBS
      PSIB  =PSIBS
      TRI   =TRIS
      SRAA  =SRAAS
      SREA  =SREAS
404   IF (LDB) 409,406,409
409   IF (ABSF(DPHIB)-3./57.2957795) 410,410,411
410   ARG2=.66666667E-1/57.2957795
      GO TO 412
411   ARG2=.66666667E-1*6./57.2957795
412   CALL QUANT (DPSIB,ARG2)
      IF (ABSF(DTHB)-3./57.2957795) 413,413,415
413   ARG2=.66666667E-1/57.2957795
      GO TO 416
415   ARG2=.66666667E-1*6./57.2957795
416   CALL QUANT (DPSIB,ARG2)
      IF (ABSF(DTHB)-3./57.2957795) 417,417,418
417   ARG2=.66666667E-1/57.2957795
      GO TO 419
418   ARG2=.66666667E-1*6./57.2957795
419   CALL QUANT (DTHB,ARG2)
406   IF (INPASS) 202,200,202
202   IF(IWRITE) 200,7001,200
7001  IF(T-CO-DELAY+1.) 201,7000,201
7000  DONPRT=4095.
201   IF(T-CO-DELAY) 121,641,641
121   IF (KEY 14) 414,120,414
120   IF(T-10.) 159,159,150
150   IF(LDO05) 154,155,154
154   IF(CTTG) 155,157,155
157   IF(FIN) 155,151,155
151   IF(DELVX) 159,152,159
152   IF(DELVY) 159,153,159
153   IF(DELVZ) 159,155,159
155   IF(TRI- ESPR) 159,159,158
C
C     FROM PAGE 78 OF THE REPORT 
158   CALL KEYS (15,KEY15)
      IF(KEY15) 112,156,112
159   CALL KEYS (19,KEY19)
      IF(KEY19) 112,156,112
156   IF(IOLP) 112,10006,112
641     CO=CO+COINT
200   CALL KEYS (20,KEY20)
      IF (KEY20) 414,120,414
414   WRITE OUTPUT TAPE KT2,642,T,NDATE1,NDATE2,NDATE3,NRUN1,NRUN2
      WRITE OUTPUT TAPE KT2,643,XI,YI,ZI
      WRITE OUTPUT TAPE KT2,1007,XRV,YRV,ZRV
      WRITE OUTPUT TAPE KT2,644,DXI,DYI,DZI
      WRITE OUTPUT TAPE KT2,92,TI
      WRITE OUTPUT TAPE KT2,645,XTI,YTI,ZTI
      WRITE OUTPUT TAPE KT2,644,DXTI,DYTI,DZTI
      WRITE OUTPUT TAPE KT2,92,TTI
      WRITE OUTPUT TAPE KT2,82,XGRT,YGRT,ZGRT
      WRITE OUTPUT TAPE KT2,83,XGRTD,YGRTD,ZGRTD
      WRITE OUTPUT TAPE KT2,15,A11,A12,A13
      WRITE OUTPUT TAPE KT2,16,A21,A22,A23
      WRITE OUTPUT TAPE KT2,16,A31,A32,A33
      WRITE OUTPUT TAPE KT2,19,T11,T12,T13
      WRITE OUTPUT TAPE KT2,16,T21,T22,T23
      WRITE OUTPUT TAPE KT2,16,T31,T32,T33
      WRITE OUTPUT TAPE KT2,17,P11,P12,P13
      WRITE OUTPUT TAPE KT2,16,P21,P22,P23
      WRITE OUTPUT TAPE KT2,16,P31,P32,P33
      WRITE OUTPUT TAPE KT2,18,PB11,PB12,PB13
      WRITE OUTPUT TAPE KT2,16,PB21,PB22,PB23
      WRITE OUTPUT TAPE KT2,16,PB31,PB32,PB33
      WRITE OUTPUT TAPE KT2,646,TRI,RAA,REA
      WRITE OUTPUT TAPE KT2,659,TRIDOT,SRAA,SREA
      WRITE OUTPUT TAPE KT2,647,THETAB,PSIB,PHIB
      WRITE OUTPUT TAPE KT2,648,FZPI,FYP1,FZP1,FXPSP,FYPSP,FZPSP
      WRITE OUTPUT TAPE KT2,649,DELVX,DELVY,DELVZ
      WRITE OUTPUT TAPE KT2,650,FTXV,FTYV,FTZV
      WRITE OUTPUT TAPE KT2,651,TFTXV,TFTYV,TFTZV
      IF(LRDFDI) 187,830,187
187   WRITE OUTPUT TAPE KT2,652,DREA,DRAA,DROLL
      GO TO 188
830   WRITE OUTPUT TAPE KT2,652,DTHB,DPSIB,DPHIB
188   WRITE OUTPUT TAPE KT2,1008
      WRITE OUTPUT TAPE KT2,653,WYV,WZV,WXV
      WRITE OUTPUT TAPE KT2,27,OMU,OMEGA,OIOTA
999   WRITE OUTPUT TAPE KT2,1029,TIME,NDATE1,NDATE2,NDATE3,NRUN1,NRUN2
      WRITE OUTPUT TAPE KT2,1034
      WRITE OUTPUT TAPE KT2,1030,     REM(  1),CT    ,REM(  2),CA11  ,
     1REM(  3),CA12  ,REM(  4),CA13  ,REM(  5),CDVT  ,REM(  6),CWTTPR,
     2REM(  7),CA21  ,REM(  8),CA22  ,REM(  9),CA23  ,REM( 10),CDVI  ,
     3REM( 11),CDEL  ,REM( 12),CA31  ,REM( 13),CA32  ,REM( 14),CA33  ,
     4REM( 15),CDVF  ,REM( 16),CTM   ,REM( 17),CSPSIR,REM( 18),CFX   ,
     5REM( 19),CX    ,REM( 20),CDVXB ,REM( 21),CDTM  ,REM( 22),CCPSIR,
     6REM( 23),CFY   ,REM( 24),CY    ,REM( 25),CDVYB ,REM( 26),CTDV  ,
     7REM( 27),CSTHR ,REM( 28),CFZ   ,REM( 29),CZ    ,REM( 30),CDVZB ,
     8REM( 31),TSC   ,REM( 32),CCTHR ,REM( 33),CDVXS ,REM( 34),CXM   ,
     9REM( 35),CDVXM
C
C     FROM PAGE 79 OF THE REPORT
      WRITE OUTPUT TAPE KT2,1030,     REM( 36),CTDAS ,REM( 37),CM1   ,
     1REM( 38),CDVYS ,REM( 39),CYM   ,REM( 40),CDVYM ,REM( 41),CRLO  ,
     2REM( 42),CM3   ,REM( 43),CDVZS ,REM( 44),CZM   ,REM( 45),CDVZM ,
     3REM( 46),CPHIB ,REM( 47),CM4   ,REM( 48),CDV   ,REM( 49),CXZ   ,
     4REM( 50),CDXD  ,REM( 51),CPSIB ,REM( 52),CM5   ,REM( 53),CSTZ  ,
     5REM( 54),CYZ   ,REM( 55),CDYD  ,REM( 56),CTHB  ,REM( 57),CM6   ,
     6REM( 58),CTD   ,REM( 59),CZZ   ,REM( 60),CDZD  ,REM( 61),CUDPHS,
     7REM( 62),COEFF ,REM( 63),CSTD  ,REM( 64),CCRI  ,REM( 65),CXTD  ,
     8REM( 66),CUDPSS,REM( 67),CCK1  ,REM( 68),CSTDL ,REM( 69),C0I   ,
     9REM( 70),CYTD
      WRITE OUTPUT TAPE KT2,1030,     REM( 71),CUDTHS,REM( 72),CCK2  ,
     1REM( 73),CWSTD ,REM( 74),C2I   ,REM( 75),CZTD  ,REM( 76),CDPHSC,
     2REM( 77),CCK3  ,REM( 78),CWSTDL,REM( 79),CCABI ,REM( 80),CXRD  ,
     3REM( 81),CDPSSC,REM( 82),CCK4  ,REM( 83),CNS   ,REM( 84),CCASI ,
     4REM( 85),CYRD  ,REM( 86),CDTHSC,REM( 87),CCK5  ,REM( 88),CTX   ,
     5REM( 89),CCRBI ,REM( 90),CZRD  ,REM( 91),CPSIBC,REM( 92),CCKF  ,
     6REM( 93),CDTX  ,REM( 94),CCRSI ,REM( 95),CDXFD ,REM( 96),CTHBC ,
     7REM( 97),CCKG  ,REM( 98),CRA   ,REM( 99),CATXBI,REM(100),CDYFD ,
     8REM(101),CPSBCP,REM(102),TEST  ,REM(103),CR1   ,REM(104),CAPTI ,
     9REM(105),CDZFD
      WRITE OUTPUT TAPE KT2,1030,     REM(106),CTHBCP,REM(107),FIN   ,
     1REM(108),CDRRD ,REM(109),CSRTI ,REM(110),CXSD  ,REM(111),CPSIBM,
     2REM(112),FP    ,REM(113),RRDREF,REM(114),CRS   ,REM(115),CYSD  ,
     3REM(116),CTHBM ,REM(117),SW    ,REM(118),CRRD  ,REM(119),COMGS ,
     4REM(120),CZSD  ,REM(121),CRRI  ,REM(122),CRRPI ,REM(123),CRRG  ,
     5REM(124),CRR   ,REM(125),CDVXZ ,REM(126),CSAPI ,REM(127),CSADPI,
     6REM(128),CSAPG ,REM(129),CSAPR ,REM(130),CDVYZ ,REM(131),CSRPI ,
     7REM(132),CSRDPI,REM(133),CSRPG ,REM(134),CSRPR ,REM(135),CDVZZ ,
     8REM(136),RDGC  ,REM(137),CTRR  ,REM(138),CTR1  ,REM(139),CTLRP ,
     9REM(140),CDTW
      WRITE OUTPUT TAPE KT2,1030,     REM(141),TVX   ,REM(142),TVY   ,
     1REM(143),TVZ   ,REM(144),TYC   ,REM(145),TPC
      WRITE OUTPUT TAPE KT2,1019,     REM(141),TVX   ,REM(142),TVY   ,
     1REM(143),TVZ   ,REM(144),TYC   ,REM(145),TPC
      WRITE OUTPUT TAPE KT2,1036,     REM(146),LC1   ,REM(147),LC4C  ,
     1REM(149),LC10  ,REM(149),LDI00 ,REM(150),IC    ,REM(151),LC1J  ,
     2REM(152),LC4D  ,REM(153),LCA   ,REM(154),LDI21 ,REM(155),KC    ,
     3REM(156),LC2   ,REM(157),LC7   ,REM(158),LCS   ,REM(159),LDO05 ,
     4REM(160),K2C   ,REM(161),LC3   ,REM(162),LC8   ,REM(163),N     ,
     5REM(164),M     ,REM(165),L
      WRITE OUTPUT TAPE KT2,1031,(CXT(I),CYT(I),CZT(I),CDTWT(I),I=1,11)
      GO TO 159
112   IF (3.14159265/6.+.05-CWTTPR) 10001,10001,10009
10009 IF (LC3) 10002,10001,10002
10002 IF(CT-(CTM+150.)) 10001,146,146
146   IF (TEST) 10001,10005,10001
10005 CALL KEYS (19,KEY19)
      IF(KEY19) 140,141,140
140   IF (MUD5) 10004,10003,10004
10003 MUD5=4095
      PRINT 1006
10004 PRINT 1009,T,XGRT,YGRT,ZGRT,XGRTD,YGRTD,ZGRTD,TRI,TRIDOT,LDI00
141   CALL KEYS (20,KEY20)
      IF(KEY20) 142,10006,142
142   WRITE OUTPUT TAPE KT2,1006
      WRITE OUTPUT TAPE KT2,1009,T,XGRT,YGRT,ZGRT,XGRTD,YGRTD,ZGRTD,TRI,
     1TRIDOT,LDI00
C     THE CONTINUATION LINE ABOVE WAS ORIGINALLY ON THE FOLLOWING PAGE.
C     FROM PAGE 80 OF THE REPORT --
      GO TO 10006
10001 CALL KEYS (19,KEY19)
      IF(KEY19) 143,144,143
143   PRINT 1003,T,XGRT,YGRT,ZGRT,CDVXSP,CDVYSP,CDVZSP,LDI21,LRDFDI
144   CALL KEYS (20,KEY20)
      IF(KEY20) 145,10006,145
145   WRITE OUTPUT TAPE KT2,1004
      WRITE OUTPUT TAPE KT2,1003,T,XGRT,YGRT,ZGRT,CDVXSP,CDVYSP,CDVZSP,
     1LDI21,LRDFDI
10006 CALL KEYS (14,KEY14)
      IF(KEY14) 7002,124,7002
124   IF(IWRITE) 7002,123,7002
7002  DONPRT=4095.
123   IF (LOC) 253,10007,253
253   KPLOT=KPLOT+1
      DUM1 =XI
      DUM2 =YI
      DUM3 =ZI
      DUM4 =DXI
      DUM5 =DYI
      DUM6 =DZI
      DUM7 =XTI
      DUM8 =YTI
      DUM9 =ZTI
      DUM10=DXTI
      DUM11=DYTI
      DUM12=DZTI
      DUM13=LC1
      DUM14=LC2
      DUM15=LC3
      DUM16=LC5
      DUM17=LC7
      DUM18=LC8
      DO 904 JP=1,LIMIT
      IPSUB=IPLST(JP)
904   TABLE1(JP,KPLOT)=VLIST(IPSUB)
      IF (KPLOT-20) 10007,255,255
255   WRITE TAPE KT3,((TABLE1(LP1,LP2),LP1=1,LIMIT),LP2=1,20)
      KPLOT=0
10007 CTE=CTE+DT
      CFX=0.
      CFY=0.
      CFZ=0.
10008 CALL KEYS (16,KEY16)
      IF (KEY16) 840,841,840
840   CALL HDA7
      CALL SELFLD
      ZZ3=CLOCKF(XX)
      ZZ3=ZZ3-ZZ2
      CALL KEYS (16,KEY16)
      IF (KEY16) 844,841,844
844   PRINT 1301, NRUN1,NRUN2,ZZ3
      WRITE OUTPUT TAPE KT2,1301,NRUN1,NRUN2,ZZ3
846   IF (LOC) 198,199,198
198   WRITE OUTPUT TAPE KT2,1298,(TABLE1(JK,20),JK=1,LIMIT)
C
C     FROM PAGE 81 OF THE REPORT 
      PRINT 1298,(TABLE1(JK,20),JK=1,LIMIT)
      END FILE KT3
199   CALL KEYS (16,KEY16)
      IF (KEY16) 336,335,336
335   IF (IEXIT) 336,330,336
336   ZZ4=CLOCKF(XX)
      ZZ4=ZZ4-ZZ1
      PRINT 1302,ZZ4
      WRITE OUTPUT TAPE KT2,1302,ZZ4
      CALL EXIT
841   IF (INPASS)654,660,654
660   INPASS=4095
      GO TO 101
654   IF (T-EOP)655,655,656
655   IF(LRDFDI) 171,831,171
171   DRAA=RAA
      DREA=REA
      DROLL=0.
      IF (ABSF(DRAA)-3.14159265) 172,173,173
173   IF (DRAA) 189,190,190
189   DRAA=DRAA+6.28318530
      GO TO 172
190   DRAA=DRAA-6.28318530
172   IF (ABSF(DREA)-3.14159265) 174,191,191
191   IF (DREA) 192,193,193
192   DREA=DREA+6.28318530
      GO TO 174
193   DREA=DREA-6.28318530
174   IF (ABSF(DRAA)-.34906585) 176,176,177
177   IF (DRAA) 178,176,179
178   DRAA=-.34906585
      GO TO 176
179   DRAA= .34906585
176   IF (ABSF(DREA)-.34906585) 180,180,181
181   IF (DREA) 182,180,183
182   DREA=-.34906595
      GO TO 180
183   DREA= .34906585
180   EXV=0.
      EZV=-DRAA
      EYV=-DREA
      XKP=XKP1
      GO TO 785
831   EXP=-DPHIB
      EYP=-DPSIB
      EZP=DTHB
770   IF (ABSF(EXP)-.04) 60,60,61
61    EYP=0.
      GO TO 362
60    IF (ABSF(EYP)-.04) 130,130,362
362   EZP=0.
130   EXV=EXP
      EYV=-EZP
      EZV=EYP
131   IF(CPSIBC-3.14159265/2.) 132,132,133
132   SIBC=CPSIBC
C
C     FROM PAGE 82 OF THE REPORT 
      GO TO 134
133   SIBC=2.*3.14159265-CPSIBC
134   IF(SIBC-1.) 135,135,136
135   XKP=XKP1
      GO TO 785
136   IF(SIBC-1.5) 137,137,138
137   XKP=XKP2
      GO TO 785
138   XKP=XKP3
785   WXV=XKR*EXV
      WYV=XKP*EYV
      WZV=XKY*EZV
      IF(ABSF(WXV)-XLIMIT)748,748,749
749   IF(WXV)789,789,790
789   WXV=-XLIMIT
      GO TO 748
790   WXV=XLIMIT
748   IF(ABSF(WYV)-XLIMIT)791,791,792
792   IF(WYV)793,793,794
793   WYV=-XLIMIT
      GO TO 791
794   WYV=XLIMIT
791   IF(ABSF(WZV)-XLIMIT)795,795,796
796   IF(WZV)797,797,798
797   WZV=-XLIMIT
      GO TO 795
798   WZV=XLIMIT
795   FTXV=0.
      FTYV=0.
      FTZV=0.
703   IF(INITAL)702,701,702
702   CALL PRT
C     2010-09-02 RSB --- THE CALL PRT IS ACTUALLY
C     SUPPOSED TO RETURN TO THE LINE FOLLOWING 
C     CALL MAR.
      GO TO 666
701   INITAL=1
      CALL MAR (9,DT/8.,RKK( 50), 25,8,MM)
C     2010-09-02 RSB --- THE FOLLOWING LINE HAD NO LINE
C     NUMBER IN THE ORIGINAL CODE.  THE REASON I ADDED IT
C     IS THAT BOTH THE PRT AND DEV SUBROUTINES ACTUALLY
C     RETURN TO THIS LINE INSTEAD OF TO THE LINES THAT
C     IMMEDIATELY FOLLOW THE CALLS.  GO FIGURE.
666   GO TO (705,811),MM
705   DA11=WZV*A12-WYV*A13
      DA12=WXV*A13-WZV*A11
      DA13=WYV*A11-WXV*A12
      DA21=WZV*A22-WYV*A23
      DA22=WXV*A23-WZV*A21
      DA23=WYV*A21-WXV*A22
      DA31=WZV*A32-WYV*A33
      DA32=WXV*A33-WZV*A31
      DA33=WYV*A31-WXV*A32
      CALL DEV
C     2010-09-02 RSB --- THE CALL DEV IS ACTUALLY
C     SUPPOSED TO RETURN TO THE LINE FOLLOWING 
C     CALL MAR.
      GO TO 666
811   IF (LDO11) 31,32,31
31    LDO11=0
33    DELVX=0.
      DELVY=0.
      DELVZ=0.
      GO TO 21
32    IF(LC2) 281,280,281
280   JUMP=0
      GO TO 288
281   IF(JUMP) 288,282,288
282   ICC=ICC+1
C
C     FROM PAGE 83 OF THE REPORT 
      JUMP=4095
288   IF (ITH(ICC)) 70, 21,70
70    IF (LDI21) 53,21,53
53    IF(CT-CTDV)  21,747,747
747   IF(T-(TSC + 10.)) 21,55,55
55    IF (LDI11) 54,56,54
56    IF(CTTG) 21,54,21
54    IF(DELVX) 1,2,4
1     IF(DELVX+(CATXFW-0.5)) 5,3,3
4     IF(DELVX-(CATXBA-0.5)) 3,3,6
3     FTXV=CDVXB
      GO TO 2
5     FTXV=-CATXFW
      GO TO 2
6     FTXV= CATXBA
2     IF(DELVY)8,9,8
8     IF(ABSF(DELVY)-(CATYB-.5))7,7,11
7     FTYV=CDVYB
      GO TO 9
11    IF(DELVY)12,9,13
12    FTYV=-CATYB
      GO TO 9
13    FTYV=CATYB
9     IF(DELV2)20,21,20
20    IF(ABSF(DELVZ)-(CATZB-.5))10,10,23
10    FTZV=CDVZB
      GO TO 21
23    IF(DELVZ)24,21,25
24    FTZV=-CATZB
      GO TO 21
25    FTZV=CATZB
21    IF(DELVX) 501,502,501
502   LDI31=0
      GO TO 507
501   LDI31=4095
507   IF(DELVY) 503,504,503
504   LDI25=0
      GO TO 508
503   LDI25=4095
508   IF(DELVZ) 505,506,505
506   LDI26=0
      GO TO 509
505   LDI26=0
509   Q37=FTXV*A11+FTYV*A12+FTZV*A13
      Q38=FTXV*A21+FTYV*A22+FTZV*A23
      Q39=FTXV*A31+FTYV*A32+FTZV*A33
      GO TO 101
656   ZZ3=CLOCKF(XX)
      ZZ3=ZZ3-ZZ2
      PRINT 1300, NRUN1,NRUN2,ZZ3
      WRITE OUTPUT TAPE KT2,1300,NRUN1,NRUN2,ZZ3
      GO TO 846
14    FORMAT(1H ,17X,8HVELOCITY,32X,3E20.8)
15    FORMAT(1H0/1H ,5X,6HMATRIX,6X,21HINERTIAL - SPACECRAFT,19X,3E20.8)
16    FORMAT(1H ,57X,3E20.8)
17    FORMAT(1H0/1H ,5X,6HMATRIX,6X,21HINERTIAL - NAVIGATION,19X,3E20.8)
C
C     FROM PAGE 84 OF THE REPORT 
18    FORMAT(1H0/1H ,5X,6HMATRIX,6X,23HSPACECRAFT - NAVIGATION,17X,
     13E20.8)
19    FORMAT(1H0/1H ,5X,6HMATRIX,6X,17HTARGET - INERTIAL,23X,3E20.8)
27    FORMAT(1H0/1H ,5X,37HORBITAL PARAMETERS  MU - OMEGA - IOTA,15X,
     13E20.8)
82    FORMAT(1H ,17X,40HS/C IN TARG. CYLINDRICAL  X-Y-Z POSITION,3E20.8)
83    FORMAT(1H ,43X,14HX-Y-Z VELOCITY,3E20.8)
92    FORMAT(1H ,17X,16HVECTOR MAGNITUDE,24X,E20.8)
642   FORMAT (1H1,5X,4HTIME,8X,18HFROM PROBLEM START,22X,E20.8,6X,
     15HDATE ,I2,1H/,I2,1H/,I2,7X,4HRUN ,A6,A6)
643   FORMAT (1H0/1H ,5X,6HGEMINI,6X,19HPOSITION - INERTIAL,21X,3E20.8)
644   FORMAT (1H ,17X,19HVELOCITY - INERTIAL,21X,3E20.8)
645   FORMAT (1H ,5X,6HTARGET,6X,19HPOSITION - INERTIAL,21X,3E20.8)
646   FORMAT (1H0/1H ,5X,5HRADAR,7X,
     135HRANGE - AZIMUTH (R) - ELEVATION (A),5X,3E20.8)
647   FORMAT    (1H0,5X,13HGIMBAL ANGLES,19H  THETA - PSI - PHI,20X,
     13E20.8)
648   FORMAT (1H0,5X,47HINTEGRATING ACCELEROMETER OUTPUTS - BEFORE COMP,
     15X,3E20.8/1H ,39X,12H- AFTER COMP,6X,3E20.8)
649   FORMAT(1H0,5X,12HDELTA V     ,14HMETER READINGS,26X,3E20.8)
650   FORMAT(1H0/1H ,5X,12HTHRUSTER    ,12HACCELERATION,28X,3E20.8)
651   FORMAT(1H0,5X,12HDELTA V     ,13HTOTAL APPLIED,27X,3E20.8)
652   FORMAT(1H0/1H ,5X,12HERROR ANGLES,40X,3E20.8)
653   FORMAT (1H ,5X,13HTURNING RATES,39X,3E20.8)
659   FORMAT (1H ,17X,28HRATE  - SINE R      - SINE A,12X,3E20.8)
1000  FORMAT (1H1,(1H0,8E15.6))
1001  FORMAT (10I3,7I6)
1002  FORMAT (6E12.8)
1003  FORMAT (1H ,5X,F9.1,3F16.1,3F10.0,2I10)
1004  FORMAT (1H0,4X,10HTIME (SEC),3X,13HTRAILING (FT),3X,
     113HVERTICAL (FT),4X,12HOUT-OF-PLANE,3X,7HX-METER,3X,7HY-METER,3X,
     27HZ-METER,5X,5HLDI21,4X,6HLRDFDI)
1005  FORMAT (O12)
1006  FORMAT (1H0,5X,4HTIME,15X,22HRELATIVE POSITION (FT),14X,
     123HRELATIVE VELOCITY (FPS),6X,22HRADAR RANTE RANGE RATE,2X,
     25HLDI00/4X,9H(SECONDS),5X,8HTRAILING,5X,8HVERTICAL,2X,
     312HOUT-OF-PLANE,3X,8HTRAILING,3X,8HVERTICAL,2X,9HOUT-PLANE,
     47X,4H(FT),8X,5H(FPS))
1007  FORMAT (1H ,26X,24H- TARGET IN GEMINI FRAME,7X,3E20.8)
1008  FORMAT (1H ,67X,5HPITCH,16X,3HYAW,17X,4HROLL)
1009  FORMAT (1H ,3X,F9.1,3F14.1,3F11.2,F14.1,F11.2,I7)
1010  FORMAT (11X,I2,1X,I2,1X,I2,10X,A6,A6)
1011  FORMAT (1H0,5HDATE ,I2,1H/,I2,1H/,I2//1H ,4HRUN ,A6,A6)
1012  FORMAT (12I6)
1013  FORMAT (1H1,5HDATE ,I2,1H/,I2,1H/,I2//1H ,4HRUN ,A6,A6)
1014  FORMAT (I2,46X,2(A6,1X,I3,2X))
1015  FORMAT (6(A6,1X,I3,2X))
1016  FORMAT (1H0,5H PLOT,6X,4HSUB-/1H ,6HSYMBOL,4X,
     16HSCRIPT//(1H ,A6,5X,I3))
1017  FORMAT (1H0,43HOPERATOR ERROR - CHECK MQ KEYS - PUSH START/1H ,
     117HPROGRAM EXPECTS  , O12  ,16H  TO BE ENTERED////)
1019  FORMAT (5(1H ,A6,O14,3X))
1029  FORMAT (1H1,7HTIME = ,E15.8,9H SECONDS.,52X,5HDATE ,I2,1H/,I2,1H/,
     1I2,7X,4HRUN ,A6,A6/)
1030  FORMAT (5(1H ,A6,E15.8,2X))
1031  FORMAT (1H0,36H11 VALUES EACH OF X,Y,Z, AND DELTA T//(1H ,4E20.8))
1032  FORMAT (12A6)    
C
C     FROM PAGE 85 OF THE REPORT 
1034  FORMAT (1H ,40HSIMULATED COMPUTER OUTPUTS ON THIS PAGE.//)
1036  FORMAT (5(1H ,A6,I6,11X))
1037  FORMAT(1H1,6HEOP   ,E15.8,3X,6HSTCT  ,E15.8,3X,6HCTZ   ,E16.8,3X,
     16HCTE   ,E15.8, 3X,6HCOINT ,E15.8/1H ,6HDELAY ,E15.8, 3X,
     26HESPR  ,E15.8, 3X,6HDT    ,E15.8, 3X,6HBINT  ,E15.8, 3X,
     36HCAPT  ,E15.8/1H ,6HCOMGT ,E15.8, 3X,6HCSRT  ,E15.8, 3X,
     46HXI    ,E15.8, 3X,6HYI    ,E15.8, 3X,6HZI    ,E15.8/1H ,
     56HDXI   ,E15.8, 3X,6HDYI   ,E15.8/1H ,6HDZI   ,E15.8, 3X,
     66HXTI   ,E15.8, 3X,6HYTI   ,E15.8, 3X,6HZTI   ,E15.8, 3X,
     76HDXTI  ,E15.8, 3X,6HDYTI  ,E15.8, 3X,6HDZTI  ,E15.8, 3X,
     86HRJ    ,E15.8/1H ,6HCATXBA,E15.8, 3X,6HCATXFW,E15.8, 3X,
     96HCATYB ,E15.8, 3X,6HCATZB ,E15.8, 3X,6HXKRDR ,E15.8)
1038  FORMAT(1H1,6HCCAB  ,E15.8,3X,6HCCAS  ,E15.8,3X,6HCCRB  ,E16.8,3X,
     16HCCRS  ,E15.8, 3X,6HCO    ,E15.8/1H ,6HC2    ,E15.8, 3X,
     26HA11   ,E15.8, 3X,6HA12   ,E15.8, 3X,6HA13   ,E15.8, 3X,
     36HA21   ,E15.8/1H ,6HA22   ,E15.8, 3X,6HA23   ,E15.8, 3X,
     46HA31   ,E15.8, 3X,6HA32   ,E15.8, 3X,6HA33   ,E15.8/1H ,
     56HAKX1  ,E15.8, 3X,6HAKX2  ,E15.8/1H ,6HAKX3  ,E15.8, 3X,
     66HAKX4  ,E15.8, 3X,6HAKY1  ,E15.8, 3X,6HAKY2  ,E15.8, 3X,
     76HAKY3  ,E15.8, 3X,6HAKY4  ,E15.8, 3X,6HAKZ1  ,E15.8, 3X,
     86HAKZ2  ,E15.8/1H ,6HAKZ3  ,E15.8, 3X,6HAKZ4  ,E15.8, 3X,
     96HXKP1  ,E15.8, 3X,6HXKP2  ,E15.8, 3X,6HXKP3  ,E15.8)
1039  FORMAT(1H ,6HXKR   ,E15.8,3X,6HXKY   ,E15.8,3X,6HCCR   ,E15.8)
1040  FORMAT(1H ,7HITH( 1),I5,3X,7HITH( 2),I5,3X,7HITH( 3),I5,3X,
     17HITH(14),I5,3X,7HITH( 5),I5/1H , 7HITH( 6),I5,3X,7HITH( 7),I5,3X,
     27HITH(28),I5,3X,7HITH( 9),I5,3X,7HITH(10),I5/1H ,6HMACOP ,I6,3X,
     36HMACNTR,I6, 3X,6HMACINT,I6, 3X,6HMODCR ,I6, 3X,6HNPF   ,I6/1H ,
     46HLOC   ,I6, 3X,6HLMDI  ,I6, 3X,6HLFP   ,I6, 3X,6HLGANG ,I6, 3X,
     56HLRR   ,I6/1H ,6HLSRA  ,I6, 3X,6HLRM   ,I6, 3X,6HLDB   ,I6, 3X,
     66HLFDI  ,I6, 3X,6HIEXIT ,I6)
1050  FORMAT (A6,2E15.8,I4)
1051  FORMAT (1H1,6HSYMBOL,8X,4HTIME,14X,4HDATA,10X,1HI//)
1052  FORMAT (1H ,A6,2E18.8,I6)
1298  FORMAT (1H ,6E16.8)
1300  FORMAT (5H RUN ,A6,A6,24H TERMINATED BY EOP AFTER,-2PF9.2,
     19H MINUTES.)
1301  FORMAT (5H RUN ,A6,A6,27H TERMINATED BY KEY 16 AFTER,-2PF9.2,
     19H MINUTES.)
1302  FORMAT (17H THIS PROGRAM RAN,-2PF9.2,9H MINUTES.)
      END(1,1,0,0,0,0,1,1,0,0,0,0,0,0,0)
